<template>
	<view>
		<u-navbar title="充电卡"></u-navbar>
		<view class="" v-show="cardcontent.je">
			<cardlook :Card="Card"></cardlook>
			<z-mine-list v-for="(item,index) in list" class="" @click="listtap(item)">
				<view style="width: 80rpx;height: 80rpx;display: flex;justify-content: center;align-items: center;">
					<view v-if="item.icon.indexOf('wxhtml')>=0" style="width: 60rpx;height: 60rpx">

						<u--image :showLoading="true" :src="item.icon" width="60rpx" height="60rpx"
							@click="click"></u--image>
					</view>

					<view v-else class="iconfont icon-chongzhi1"></view>

				</view>
				{{$z.$t(item.text)}}
			</z-mine-list>
		</view>
		<zmodal ref="zmodal"></zmodal>
	</view>
</template>

<script>
	// import settingvue from "@/mixins/setting.vue"
	import {
		DataURLimg
	} from "@/config/index.js"
	export default {
		data() {
			return {
				DataURLimg,
				bjimg1: `url('${DataURLimg}/kabj.png')`,
				bjimg2: `url('${DataURLimg}/kabj2.png')`,
				img1: `${DataURLimg}/cz.png`,
				USearch: {},
				umodaldata: {},
				Card: {},
				cardcontent: {},
				list: []
			}
		},
		// mixins: [settingvue],
		onShow() {
			this.getdata();
		},
		methods: {
			listtap(item) {
				if (item.page) {
					this.$z.gopage(item.page)
				} else if (item.callback) {
					item.callback()
				}
			},
			async getdata() {
				let data = await this.$store.dispatch("user/getuser")
				// data = data[0];
				// data.printid = "E_240124150315170";
				this.USearch = data;
				let Card = await this.$z.request("/Card", {
					printid: data.printid
				})
				if (Card.length == 0) {
					this.$refs.zmodal.init({
						content: this.$z.$t("该卡已被管理员删除无法使用是否解绑"),

						confirm: () => {
							uni.$z.request("/CardTouUserdel", {
								printid: data.printid
							}).then(e => {
								uni.$u.toast(this.$z.$t("解绑成功"))
								uni.navigateBack()
							})
						}
					})

					return;
				}

				this.Card = Card[0];
				this.cardcontent = this.$z.cardcontent(this.Card);
				console.log();
				let list = [];
				if (this.Card.b_use == 1) {
					if (this.Card.type != 6) {
						list.push({
							icon: `${this.DataURLimg}/cz.png`,
							text: this.$z.$t("卡充值"),
							page: "/pages/card/pay/pay?printid=" + this.Card.printid
						})
					}
					if (this.cardcontent.ctype != 1) {
						list.push({
							icon: `${this.DataURLimg}/kgs.png`,
							text: this.$z.$t("卡挂失"),
							callback: () => {
								this.$refs.zmodal.init({
									content: this.$z.$t("挂失后卡将无法使用,继续挂失?"),
									showTitle: false,
									showcancel: true,
									confirm: () => {
										uni.$z.gopage(
											`/pages/card/Cardsetting/cardb_use/cardb_use?printid=${this.Card.printid}&url=CardLoss&title=卡挂失`
										)
									}
								})

							}
						})
					}
				}
				// else if (this.cardcontent.ctype != 1) {
				// 	list.push({
				// 		icon: `${this.DataURLimg}/kzc.png`,
				// 		text: this.$z.$t("卡挂失后恢复正常"),
				// 		callback: () => {
				// 			this.$refs.zmodal.init({
				// 				content: this.$z.$t("卡已找到,取消挂失?"),
				// 				showTitle: false,
				// 				showcancel: true,
				// 				confirm: () => {
				// 					uni.$z.gopage(
				// 						`/pages/card/Cardsetting/cardb_use/cardb_use?printid=${this.Card.printid}&url=CardRec&title=取消挂失`
				// 					)
				// 				}
				// 			})

				// 		}
				// 	})
				// }

				if (this.cardcontent.ctype != 1) {
					list.push({
						icon: `chongzhi`,
						text: this.$z.$t("卡充值记录"),
						callback: () => {
							uni.$z.gopage(
								`/pages/card/Cardsetting/GetRfCZCard/GetRfCZCard?printid=${this.Card.printid}`
							)
						}
					})
				}
				if (this.cardcontent.ctype != 1) {
					list.push({
						icon: `${this.DataURLimg}/kjb.png`,
						text: this.$z.$t("解绑卡号"),
						callback: () => {
							this.$refs.zmodal.init({
								content: this.$z.$t("确认解绑当前卡号?"),
								showTitle: false,
								showcancel: true,
								confirm: () => {
									uni.$z.gopage(
										`/pages/card/Cardsetting/cardb_use/cardb_use?printid=${this.Card.printid}&url=CardTouUserdel&title=解绑卡号`
									)
								}
							})

						}
					})
				}
				this.list = list;
			}
		}
	}
</script>

<style lang="scss">
	.icon-chongzhi1 {
		font-size: 50rpx;
		color: #339CF5;
	}
</style>